package per.ethan.cloud.provider.api.factory;

import feign.hystrix.FallbackFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import per.ethan.cloud.provider.api.RemotePaymentService;
import per.ethan.cloud.provider.api.fallback.RemotePaymentServiceFallbackImpl;

/**
 * @author Ethan
 * @date 2020/03/28 14:14
 */
@Component
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class RemotePaymentServiceFallbackFactory implements FallbackFactory<RemotePaymentService> {

    private final RemotePaymentServiceFallbackImpl remotePaymentServiceFallback;

    @Override
    public RemotePaymentService create(Throwable cause) {
        remotePaymentServiceFallback.setCause(cause);
        return remotePaymentServiceFallback;
    }

}
